#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["samples/RayPI.OpenApi/RayPI.OpenApi.csproj", "samples/RayPI.OpenApi/"]
COPY ["samples/RayPI.Repository.EFRepository/RayPI.Repository.EFRepository.csproj", "samples/RayPI.Repository.EFRepository/"]
COPY ["samples/RayPI.Domain/RayPI.Domain.csproj", "samples/RayPI.Domain/"]
COPY ["src/Ray.Domain/Ray.Domain.csproj", "src/Ray.Domain/"]
COPY ["src/Ray.Infrastructure/Ray.Infrastructure.csproj", "src/Ray.Infrastructure/"]
COPY ["src/Ray.Auditing/Ray.Auditing.csproj", "src/Ray.Auditing/"]
COPY ["src/Ray.Security/Ray.Security.csproj", "src/Ray.Security/"]
COPY ["samples/RayPI.Infrastructure.Treasury/RayPI.Infrastructure.Treasury.csproj", "samples/RayPI.Infrastructure.Treasury/"]
COPY ["src/Ray.Repository.EfCore/Ray.Repository.EfCore.csproj", "src/Ray.Repository.EfCore/"]
COPY ["src/Ray.Guids/Ray.Guids.csproj", "src/Ray.Guids/"]
COPY ["samples/RayPI.Infrastructure.Config/RayPI.Infrastructure.Config.csproj", "samples/RayPI.Infrastructure.Config/"]
COPY ["samples/RayPI.Infrastructure.Auth/RayPI.Infrastructure.Auth.csproj", "samples/RayPI.Infrastructure.Auth/"]
COPY ["samples/RayPI.Infrastructure.Security/RayPI.Infrastructure.Security.csproj", "samples/RayPI.Infrastructure.Security/"]
COPY ["samples/RayPI.Infrastructure.Swagger/RayPI.Infrastructure.Swagger.csproj", "samples/RayPI.Infrastructure.Swagger/"]
COPY ["samples/RayPI.Application/RayPI.Application.csproj", "samples/RayPI.Application/"]
COPY ["src/Ray.ObjectMap.AutoMapper/Ray.ObjectMap.AutoMapper.csproj", "src/Ray.ObjectMap.AutoMapper/"]
COPY ["src/Ray.ObjectMap/Ray.ObjectMap.csproj", "src/Ray.ObjectMap/"]
COPY ["src/Ray.Application/Ray.Application.csproj", "src/Ray.Application/"]
COPY ["samples/RayPI.Infrastructure.Cors/RayPI.Infrastructure.Cors.csproj", "samples/RayPI.Infrastructure.Cors/"]
COPY ["samples/RayPI.Infrastructure.ExceptionManager/RayPI.Infrastructure.RayException.csproj", "samples/RayPI.Infrastructure.ExceptionManager/"]
RUN dotnet restore "samples/RayPI.OpenApi/RayPI.OpenApi.csproj"
COPY . .
WORKDIR "/src/samples/RayPI.OpenApi"
RUN dotnet build "RayPI.OpenApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "RayPI.OpenApi.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RayPI.OpenApi.dll"]